/*
 * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved.
 */
package org.schemeway.plugins.schemescript.editor;

import org.eclipse.help.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.text.ITextSelection;


/**
 * @author SchemeWay Project.
 * Provides information about the context of SchemeEditor.
 */
public class ContextProvider implements IContextProvider {

	private String contextId;
	private ITextSelection selected;

	/**
	 * Created by SchemeEditor.
	 */
	public ContextProvider(String id, ITextSelection selection) {
		contextId = id;
		selected = selection;
	}

	@Override
	public IContext getContext(Object target) {
		IContext context = HelpSystem.getContext(contextId);
		if (!selected.isEmpty()) {
			context = new SelectionContext(context, selected);
		}
		return context;
	}

	//Poll on every selection change
	@Override
	public int getContextChangeMask() {
		return SELECTION;
	}

	@Override
	public String getSearchExpression(Object target) {
		return null;
	}

}
